package demo1;

public class Test7 {
    public static void main(String[] args) throws InterruptedException {
         Thread t1 = new Thread(()->{
             for (int i = 0; i < 5; i++) {
                 System.out.println("t1");
                 try {
                     Thread.sleep(1000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
             }
         });
          Thread t2 = new Thread(()->{
              try {
                  t1.join(2000);
                  for (int i = 0; i < 5; i++) {
                      System.out.println("t2");
                      Thread.sleep(1000);
                  }
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }

          });
        t1.start();
        t2.start();
        System.out.println(t1.getState());
        System.out.println(t2.getState());

    }
}
